<?php
$this->breadcrumbs=array(
	'Services'=>array('index'),
	$model->id,
);

$this->menu=array(
	array('label'=>'List Service', 'url'=>array('index')),
	array('label'=>'Create Service', 'url'=>array('create')),
	array('label'=>'Update Service', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete Service', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>"Deleting Service will lead to deleting related Part Action record. \n Are you sure you want to delete this item?")),
	array('label'=>'Manage Service', 'url'=>array('admin')),
);
?>

<h1>View Service #<?php echo $model->id; ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		'id',
		array(
			'name'=>'date',
			'type'=>'datetime',
			'value'=>strtotime($model->date)
		),
		array(
			'name'=>'status',
			'value'=>Service::getStatusArray($model->status),
		),
		
		//customer infomation
		'firstName',
		'LastName',
		'customerAccountNo',
		'address',
		'suburb',
		'postcode',
		'state',
		'homePhone',
		'workPhone',
		'mobile',
		'email',
	   /*array(
			'name'=>'stairs',
			'type'=>'boolean',
		),*/
		
		//start of product.
		array(
			'name'=>'productId',
			'type'=>'raw',
			'value'=>CHtml::link($model->product->name."(".$model->product->model.")",
				array("product/view","id"=>$model->productId))
		),
		'serialNo',
		array(
			'name'=>'purchaseDate',
			'type'=>'date',
			'value'=>strtotime($model->purchaseDate)
		),
		array(
			'name'=>'warranty',
			'type'=>'boolean',
		),
		array(
			'name'=>'storeId',
			'type'=>'raw',
			'value'=>CHtml::link($model->store->name."(". $model->store->code.")", 
				array("store/view","id"=>$model->storeId))
		),
		'storeTinNo',		
		'faultDescription',		
		'otherInstruction',
		
		//start of payment		
		array(
			'name'=>'chargeApplicable',
			'type'=>'boolean',
		),
		'customerCharge',
		array(
			'name'=>'paymentType',
			'value'=>$model->paymentType ? $model->servicePayment->paymentType : null,
		),
		array(
			'name'=>'fundsRecovered',
			'type'=>'boolean',
		),

		//start of technician information
		array(
			'name'=>'technicianId',
			'type'=>'raw',
			'value'=>$model->technician?CHtml::link($model->technician->name,array("installer/view","id"=>$model->technicianId)):'Not Allocated'
		),
		array(
			'name'=>'technicainPaid',
			'type'=>'boolean',
		),
		'technicainPaidAmount',
		array(
			'name'=>'workCarriedOut',
			'type'=>'boolean',
		),
		array(
			'name'=>'dateCommenced',
			'type'=>'datetime',
			'value'=>$model->dateCommenced ? strtotime($model->dateCommenced): null,
		),
		array(
			'name'=>'dateCompleted',
			'type'=>'datetime',
			'value'=>$model->dateCompleted ? strtotime($model->dateCompleted): null,
		),
		'generalComment',
		'partComment',		
		'note',
		'emailNote',		
	),
)); 
?>
<div>
<?php  echo CHtml::link('Create Part Action',array('partAction/create','serviceId'=>$model->id));?>
</div>
<?php 
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'part-action-grid',
	'dataProvider'=>new CArrayDataProvider($model->partActions),
	'columns'=>array(
		array(
			'header'=>'Part',
			'type'=>'raw',
			'value'=>'CHtml::link($data->part->name."(".$data->part->num.")",
				array("sparePart/view","id"=>$data->part->id), array("target"=>"_blank"))',
		),
		'requestQty:text:Request Qty',
		'usedQty:text:Used Qty',
		array(
			'class'=>'CButtonColumn',
			'template'=>'{update} {delete}',
			'updateButtonUrl'=>'Yii::app()->controller->createUrl("partAction/update",array("id"=>$data->primaryKey))',
			'deleteButtonUrl'=>'Yii::app()->controller->createUrl("partAction/delete",array("id"=>$data->primaryKey))',
			
		),
	),
)); 
?>
